from tcis.models import Director
from tcis.models import Thesis

from django.contrib import admin

class ThesisInline(admin.TabularInline):
    model = Thesis
  
class DirectorAdmin(admin.ModelAdmin):
    #inlines = [ThesisInline,]
    """ Para mostrar una vista previa antes de presentar el listado"""
    def change_view(self, request, object_id, extra_context=None):
        result = super(DirectorAdmin, self).change_view(request, object_id, extra_context)
        #director = Director.objects.get(id__exact=object_id)
        director = Director.objects.get(id=object_id)
        if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'):
            print ' probando: %s' % director
            result['Location'] = director.get_absolute_url()
        return result

class ThesisAdmin(admin.ModelAdmin):
    pass

admin.site.register(Director,DirectorAdmin)
admin.site.register(Thesis, ThesisAdmin)
